

func (rf *Raft) RequestVoteV1(args *RequestVoteArgs, reply *RequestVoteReply) {
	// Your code here (2A, 2B).
	// lock?
	rf.mu.Lock()
	defer rf.mu.Unlock()
	reply.Term = rf.currentTerm
	reply.VoteGranted = true
	// candidate 遇到更高term的candidate，投票给它
	if rf.voteFor != -1 {
		reply.VoteGranted = false
		if rf.voteFor == args.CandidateId {
			reply.VoteGranted = true
		}
	} else if rf.role == CANDIDATE {
		// term落后需要投票
		if args.Term > rf.currentTerm {
			reply.VoteGranted = true
		} else {
			reply.VoteGranted = false
		}
	} else if rf.role == LEADER {
		// 如果leader是落后的肯定也要投票
		reply.VoteGranted = false
	} else if args.Term < rf.currentTerm {
		reply.VoteGranted = false
	} else {
		rf.voteFor = args.CandidateId
	}
}